package net.xdclass.controller;

import net.xdclass.enums.DomainTypeEnum;
import net.xdclass.model.DomainDO;
import net.xdclass.service.DomainService;
import net.xdclass.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 二当家小D
 * @since 2025-09-05
 */
@RestController
@RequestMapping("/api/domain/v1")
public class DomainController {
	@Autowired
	private DomainService domainService;

	@GetMapping("listAll")
	public JsonData listAll(){
		List <DomainDO> list = domainService.listAll();
		return  JsonData.buildSuccess(list);
	}
	@PostMapping("add")
	public JsonData add(@RequestBody DomainDO domainDO){
		int rows  = domainService.add(domainDO);
		return  JsonData.buildSuccess(rows);
	}
	@GetMapping("detail")
	public JsonData findByDomainTypeAndID(@RequestParam Long id, @RequestParam DomainTypeEnum domainTypeEnum){
		DomainDO domainDO = domainService.findByDomainTypeAndID(id,domainTypeEnum);
		return  JsonData.buildSuccess(domainDO);
	}
}

